From 41bd30a5b483749aed65ac61af17aa2235cab4e6 Mon Sep 17 00:00:00 2001 From: Alastair Tse Date: Fri, 6 Oct 2006 12:30:46 +0100 Subject: [PATCH] [XEND] Keep track of attached vbds and vifs for XenAPI Signed-off-by: Alastair Tse --- tools/python/xen/xend/XendAPI.py | 4 +++- tools/python/xen/xend/XendConfig.py | 9 ++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/tools/python/xen/xend/XendAPI.py b/tools/python/xen/xend/XendAPI.py index 042fd5b359..402e0bcbce 100644 --- a/tools/python/xen/xend/XendAPI.py +++ b/tools/python/xen/xend/XendAPI.py @@ -833,7 +833,9 @@ class XendAPI: def vm_get_by_label(self, session, label): xendom = XendDomain.instance() dom = xendom.domain_lookup_nr(label) - return xen_api_success(dom.get_uuid()) + if dom: + return xen_api_success(dom.get_uuid()) + return xen_api_error(XEND_ERROR_VM_INVALID) def vm_create(self, session, vm_struct): xendom = XendDomain.instance() domuuid = xendom.create_domain(vm_struct) diff --git a/tools/python/xen/xend/XendConfig.py b/tools/python/xen/xend/XendConfig.py index 1dab6886d8..ba6337b0c5 100644 --- a/tools/python/xen/xend/XendConfig.py +++ b/tools/python/xen/xend/XendConfig.py @@ -726,7 +726,10 @@ class XendConfig(dict): raise XendConfigError("XendConfig: device_add requires some " "config.") - log.debug("XendConfig.device_add: %s" % str(cfg_sxp)) + if cfg_sxp: + log.debug("XendConfig.device_add: %s" % str(cfg_sxp)) + if cfg_xenapi: + log.debug("XendConfig.device_add: %s" % str(cfg_xenapi)) if cfg_sxp: config = sxp.child0(cfg_sxp) @@ -743,6 +746,8 @@ class XendConfig(dict): dev_uuid = dev_info.get('uuid', uuid.createString()) dev_info['uuid'] = dev_uuid self['device'][dev_uuid] = (dev_type, dev_info) + if dev_type in ('vif', 'vbd'): + self['%s_refs' % dev_type].append(dev_uuid) return dev_uuid if cfg_xenapi: @@ -761,6 +766,7 @@ class XendConfig(dict): dev_uuid = cfg_xenapi.get('uuid', uuid.createString()) dev_info['uuid'] = dev_uuid self['device'][dev_uuid] = (dev_type, dev_info) + self['vif_refs'].append(dev_uuid) return dev_uuid elif dev_type == 'vbd': @@ -774,6 +780,7 @@ class XendConfig(dict): dev_uuid = cfg_xenapi.get('uuid', uuid.createString()) dev_info['uuid'] = dev_uuid self['device'][dev_uuid] = (dev_type, dev_info) + self['vbd_refs'].append(dev_uuid) return dev_uuid -- 2.30.2